package cc.shacocloud.luanniao.web.controller.interceptor

import cc.shacocloud.luanniao.core.model.constant.UserNamespaceRoleEnum

/**
 *  使用该注解标识则标识该接口的认证规则
 * @author 思追(shaco)
 */
@Target(
    AnnotationTarget.FUNCTION,
    AnnotationTarget.CLASS
)
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
annotation class NamespacePermission(
    /**
     * 满足认证条件的角色
     */
    val role: UserNamespaceRoleEnum,
)

/**
 * 命名空间读写+管理权限
 * @author 思追(shaco)
 */
@Target(
    AnnotationTarget.FUNCTION,
    AnnotationTarget.CLASS
)
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
@NamespacePermission(
    role = UserNamespaceRoleEnum.OWNER
)
annotation class NamespaceOwnerAuth

/**
 * 命名空间读写权限
 *
 * @author 思追(shaco)
 */
@Target(
    AnnotationTarget.FUNCTION,
    AnnotationTarget.CLASS
)
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
@NamespacePermission(
    role = UserNamespaceRoleEnum.COLLABORATORS
)
annotation class NamespaceCollaboratorsAuth

/**
 * 命名空间只读权限
 *
 * @author 思追(shaco)
 */
@Target(
    AnnotationTarget.FUNCTION,
    AnnotationTarget.CLASS
)
@Retention(AnnotationRetention.RUNTIME)
@MustBeDocumented
@NamespacePermission(
    role = UserNamespaceRoleEnum.VISITORS
)
annotation class NamespaceVisitorsAuth
